const getPropValue = require('../common/utility.js').getPropValue;

function getObjectPropertyByKeyInAst(properties_ast,key){
	if((!properties_ast)||(!properties_ast.length)||(!properties_ast.push)){
		return null;
	}

	for(var i=0; i<properties_ast.length; i++) {
		var property = properties_ast[i];
		if(!property)continue;
		const key_name = getPropValue(property, ['key', 'name']);
		if(key_name===key){
			return property.value;
		}
	}

	return null;


}

module.exports = getObjectPropertyByKeyInAst;

